package com.newegg.research;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

public class Category
{
	private String category_name;

	private Map<String, Token> tokens = new HashMap<String, Token>();

	Category(String name)
	{
		setCategory_name(name);
	}

	public String getCategory_name()
	{
		return category_name;
	}

	public void setCategory_name(String category_name)
	{
		this.category_name = category_name;
	}

	public int hashCode()
	{
		return category_name.hashCode();
	}

	public boolean equals(Object obj)
	{
		if (obj == null)
			return false;
		else if (obj instanceof Category)
		{
			if (((Category) obj).getCategory_name().equals(this.category_name))
				return true;
		}
		return false;
	}

	public void addToken(Token t)
	{
		tokens.put(t.getContent(), t);

	}

	public String toString()
	{
		return category_name;
	}

	public List getAllToken()
	{
		List<Token> list = new ArrayList<Token>(tokens.size());
		Set set = tokens.entrySet();
		Iterator it = set.iterator();
		while (it != null && it.hasNext())
		{
			Token t = (Token) ((Entry) it.next()).getValue();
			list.add(t);
		}
		return list;
	}

	// public int getWords_count()
	// {
	// return words_count;
	// }
	//
	// public void setWords_count(int words_count)
	// {
	// this.words_count = words_count;
	// }
}
